# SumOfFirstTen.py # # Description: Returns the sum of the first 10 integral numbers. # # NOTE: This algorithm is known as a “running sum” # # Anne Lavergne # Date: Feb. 9 2024 def sumOfFirstTen(): """Returns the sum of the first 10 integral numbers.""" # Initialize the accumulator variable to 0 # We use "0" because we are adding numbers theSum = 0 # For each of the first 10 integral numbers for each in range(1,11): # 1,2,3,4,5,6,7,8,9,10 # Add the number to the accumulator (running sum) theSum += each # theSum = each + theSum # Once done, return the result produced by this function: # i.e., the sum of the first 10 integral numbers. return theSum #*** Main part of my program # Call sumOfFirstTen and print its resulting sum print(F"The sum of the first 10 integral numbers is {sumOfFirstTen()}.")